% GAUTIER LE BIHAN - 2020
% Replication files for "Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector 
% Menu-Cost Model" Review of Economics and Statistics
% Compute additional simulated moments for Appendix Figure C


clear;
tic
NSectors = 1;
sm = 0.0;
addpath('..\..\Utilities')  


p0=[0.004:0.003:0.065]';
mu_c=[0.003:0.002:0.05]';
sig_eps=[0.015:0.0015:0.06]';
rho_a=[0.5:0.02:0.95]';

s=size(p0,1)+size(mu_c,1)+size(sig_eps,1)+size(rho_a,1);
param0=[tanh(0.0490584431344758); 0.0315640909562270; exp(-3.26389330290137); tanh(0.781262143955240)];
param=repmat(param0,1,s)';

param(1:size(p0),1)=p0;
param(size(p0)+1:size(p0)+size(mu_c),2)=mu_c;
param(size(p0)+size(mu_c)+1:size(p0)+size(mu_c)+size(sig_eps),3)=sig_eps;
param(size(p0)+size(mu_c)+size(sig_eps)+1:size(p0)+size(mu_c)+size(sig_eps)+size(rho_a,1),4)=rho_a;

s=size(param);
mu_vec=0.00125;

size_mu=1;
for ii=1:size_mu;
    
mu_loop=mu_vec*ii;
     fprintf("ii");
     disp(ii);
%for jj=1+s*(ii-1):ii*s;
for jj=1:s;
     fprintf("jj");
     disp(jj);
     %"i" i);
    p0=param(jj,1);
    mu_c=param(jj,2);
    sig_eps_a=param(jj,3);
    %p_a=param(jj,4); 
    rho_a=param(jj,4);
    weight_j=0.57;    
 
   [f2, avfracup2,    med2,med21,med22,   interq2, kur2]=geNCalvoPlus_SMM(mu_loop, p0, mu_c, sig_eps_a, rho_a, weight_j);
 
  stat_temp(jj,:)=[ii param(jj,:) f2 avfracup2      med2    interq2 kur2 med21 med22];

  save stat_outsample_1118egb stat_outsample_1118egb;
end

stat_outsample_1118base(1+s*(ii-1):ii*s,:)=stat_temp


end